package common.BaseView
{
	import com.lz.football.module.bag.item.BagItem;
	
	import flash.events.MouseEvent;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	public class GoodItem extends BagItem
	{
		public function GoodItem()
		{
			super();
		}
		/**
		 * 添加事件
		 * 
		 */		
		override public function addEvtListener():void
		{
			this.addEventListener(MouseEvent.ROLL_OVER,onOverHandler);
			this.addEventListener(MouseEvent.ROLL_OUT,onOutHandler);
		}
		override public function removeEvtListener():void
		{
			this.removeEventListener(MouseEvent.ROLL_OVER,onOverHandler);
			this.removeEventListener(MouseEvent.ROLL_OUT,onOutHandler);
			super.removeEvtListener();
		}
		/**
		 *显示数量 
		 * 
		 */
		public function showNum($num:int):void
		{
			if($num <= 1)return;
			var tx:TextField = createText(TextFieldAutoSize.RIGHT);
			tx.x = this.width-tx.width - 5;
			tx.y = this.height - tx.height;
			tx.text = $num + "";
			this.addChild(tx);
		}
		
		/**
		 *显示物品名称和数量 
		 * 
		 */
		public function showNameAndNum($str:String):void
		{
			var tx:TextField = createText( TextFieldAutoSize.CENTER);
			tx.x = -15;
			tx.y = 60;
			tx.width = 90;
			
			tx.text = $str + "";
			this.addChild(tx);
		}
		/**
		 * 创建文本 
		 * @return 
		 * 
		 */		
		private function createText($align:String):TextField
		{
			var tx:TextField = new TextField();
			tx.height = 20;
			tx.width = 30;
			tx.textColor = 0xFFCC00;
			tx.mouseEnabled = false;
			tx.text = "---";
			tx.y = 60;
			var tf:TextFormat =new TextFormat();
			tf.align = $align//TextFieldAutoSize.RIGHT;
			tx.defaultTextFormat = tf;
			tx.text = "---";
			
			var filter:GlowFilter = new GlowFilter(0x000000);
			filter.alpha = 0.75;
			filter.blurX = 2;
			filter.blurY = 2;
			filter.strength = 10;
			filter.quality = BitmapFilterQuality.HIGH;
			
			tx.filters = [filter];
			return tx;
		}
		override public function destroyView():void
		{
			removeEvtListener();
			if(this.parent)
				this.parent.removeChild(this);
			super.destroyView();
		}
	}
}